const mongoose = require('mongoose');

// 链接MongoDB数据库
const connectDB = async () => {
  try {
    // await mongoose.connect('mongodb://101.200.194.180:27017/bt_test', {
    // await mongoose.connect('mongodb://101.200.194.180:27017/certishare', {
    await mongoose.connect('mongodb://certishare:kytaXacs46Jp33HT@101.200.194.180:27017/certishare', {
      useNewUrlParser: true,
      useUnifiedTopology: true
    });
    console.log('MongoDB数据库连接成功');
  } catch (err) {
    console.error('MongoDB数据库连接失败:', err);
  }
};

// 导出连接函数
module.exports = connectDB;
